/**
 * 文件上传类
 * @author 郑翎
 * 2015-10-1 11:07:43
 */

package com.cbts.action.travel;

import java.io.File;
import java.util.List;
import org.apache.struts2.ServletActionContext;
import com.cbts.entity.ApplayReim;
import com.cbts.entity.Receipt;
import com.cbts.service.travel.ApplayReimService;
import com.opensymphony.xwork2.ActionSupport;

public class UploadFileAction extends ActionSupport {

	private List<File> file; 						 // 文件列表
	private List<String> fileFileName; 				 // 文件名
	private List<String> fileContentType;			 // 文件类型
	private Receipt receipt; 						 // 收据
	private ApplayReim applayReim; 			 		 // 报销记录
	private ApplayReimService applayReimService;	 // 报销的业务逻辑处理类
	private String userid; 							 // 获取session中的userid

	@Override
	public String execute() {
		try {
			// 保存文件及报销记录
			boolean b = applayReimService.saveApplayReim(file,
					this.getFileFileName(), receipt, applayReim,
					this.getUserid());
			if (b == true) {
				return INPUT;
			} else {
				return SUCCESS;
			}

		} catch (Exception e) {
			return SUCCESS;
		}
	}

	public List<File> getFile() {
		return file;
	}

	public void setFile(List<File> file) {
		this.file = file;
	}

	public List<String> getFileFileName() {
		return fileFileName;
	}

	public void setFileFileName(List<String> fileFileName) {
		this.fileFileName = fileFileName;
	}

	public List<String> getFileContentType() {
		return fileContentType;
	}

	public void setFileContentType(List<String> fileContentType) {
		this.fileContentType = fileContentType;
	}

	public Receipt getReceipt() {
		return receipt;
	}

	public void setReceipt(Receipt receipt) {
		this.receipt = receipt;
	}

	public ApplayReim getApplayReim() {
		return applayReim;
	}

	public void setApplayReim(ApplayReim applayReim) {
		this.applayReim = applayReim;
	}

	public ApplayReimService getApplayReimService() {
		return applayReimService;
	}

	public void setApplayReimService(ApplayReimService applayReimService) {
		this.applayReimService = applayReimService;
	}

	public String getUserid() throws Exception {
		try {
			userid = ServletActionContext.getContext().getSession()
					.get("userid").toString();
		} catch (Exception e) {
			throw e;
		}
		return userid;
	}

	public void setUserid(String userid) {
		this.userid = userid;
	}
}